package com.easy.service.impl;

import com.easy.bean.Employee_attendance;
import com.easy.mapper.EmployeeAttendanceDao;
import com.easy.service.EmployeeAttendanceService;
import com.easy.util.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EmployeeAttendanceServiceImpl implements EmployeeAttendanceService {

    @Autowired
    EmployeeAttendanceDao attendanceDao;

    @Override
    public Employee_attendance add(Employee_attendance attendance) {
        if (attendance.getIs_deleted() == null) {
            attendance.setIs_deleted((byte)0); // 默认未删除
        }
        attendanceDao.add(attendance);
        return attendanceDao.one(attendance.getId());
    }

    @Override
    public int del(Integer id) {
        return attendanceDao.del(id);
    }

    @Override
    public Employee_attendance edit(Employee_attendance attendance) {
        attendanceDao.edit(attendance);
        return attendanceDao.one(attendance.getId());
    }

    @Override
    public List<Employee_attendance> all(Integer employee_id) {
        return attendanceDao.all(employee_id);
    }

    @Override
    public Employee_attendance one(Integer id) {
        return attendanceDao.one(id);
    }

    @Override
    public void page(Page page, Employee_attendance attendance) {
        int count = attendanceDao.pageCount(attendance);
        Object data = attendanceDao.page(page, attendance);
        page.setCount(count);
        page.setData(data);
    }
}

